#pragma once

#include "../Core/LinearCombination3.h"
#include "KnotVectors.h"

namespace cagd
{
    // even if the type of the B-spline curve is periodic
    // we store only n + 1 control points in the _data variable of
    // the base class LinearCombination3 (note that repeated control points
    // do not increase the number of unknown parameters)
    //
    // in order to access the repeated control points of a periodic B-spline
    // curve, one can use the modulo operation with divisor n + 1
    class BSplineCurve3: public LinearCombination3
    {
    protected:
        GLuint     _n;   // n + 1 denotes the number of unrepeated control points
        KnotVector *_kv; // knot vector specified by the user

    public:
        BSplineCurve3(KnotVector::Type type, GLuint k, GLuint n, GLdouble u_min = 0.0, GLdouble u_max = 1.0, GLenum data_usage_flag = GL_STATIC_DRAW);

        // homework: using the specified knot vector, redeclare and define the inherited pure virtual methods
        //           (calculate at least the zeroth order derivatives)
        GLboolean BlendingFunctionValues(GLdouble u, RowMatrix<GLdouble>& values) const;
        GLboolean CalculateDerivatives(GLuint max_order_of_derivatives, GLdouble u, Derivatives& d) const;

        // homework: free the dynamically allocated knot vector
        ~BSplineCurve3();
    };
}
